package com.chen.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/b")
public class ServletB extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("B 执行了");
        // 一旦发现获取请求体中的参数产生乱码的时候就需要使用 HttpServletRequest
        // 对象中 setCharacterEncoding 来设置使用哪种字符集解析请求体中的参数
        req.setCharacterEncoding("UTF-8");
       /* System.out.println(req.getParameter("username"));
        System.out.println(req.getAttribute("age"));*/
        System.out.println(req.getParameter("username"));
    }
}
